<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta name="format-detection" content="telephone=no" />
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <link rel="stylesheet" href="../../static/mobile/default/css/layout.css?v=2" />
    <link rel="icon" type="image/png" href="../../static/favicon.ico" />
        <script src="../../static/js/jquery/jquery/2.1.4/jquery.min.js"></script> 
    <script src="../../static/js/jquery/jquery.cookie.js"></script>
    <script src="../../static/mobile/default/js/page.js?v=1"></script>  
    <script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <title>结算 - 达漂亮</title>

    <link rel="stylesheet" href="../../static/mobile/default/css/payment.css" />
    <script type="text/javascript">
        var orderTotal = 0,
            shippingFee = 0,
            bonus_list=  [],
            bonus_money = 0,
            totalGoodsPrice = 0,
            payTotalTemp = 0,
            used_bonus_id = '';
        var offlineChoose = false;
        var supplyerShippingFee = new Object();
    </script>


</head>

<body>
    <div class="page payment payment_coupons">
        <div class="page-hd">
            <div class="header base-header bor-1px-b">
                <div class="header-left">
                    <a href="javascript:history.go(-1)" class="left-arrow"></a>
                </div>
                <div class="header-title">结算</div>
                <div class="header-right">
                    <!-- <a href=""></a> -->
                </div>
            </div>
        </div>
        <div class="page-bd">
            <!-- 收货地址-->
            <div class="top addressBox">
                <!-- 没收货地址 -->
                <a href="javascript:;" class="tips fs30 fw_b color_9 sss1">你还没有收货地址，<span class="color_3">去添加</span></a>
                <!-- 收货地址 -->
                <a href="javascript:;" class="address sss2">
                    <div>
                        <p class="fs30 fw_b color_3 _consignee"></p><span class="fs28 color_9 _address"></span>
                        <input type="hidden" id="address_id" value="0">
                    </div>
                    <img src="../../static/mobile/default/images/rightIcon.png" alt="">
                </a>
            </div>
            <link rel="stylesheet" href="../../static/mobile/default/css/myaddress.css?v=2">
            <link rel="stylesheet" href="../../static/mobile/default/css/cityPicker.css">
            <link rel="stylesheet" href="../../static/mobile/default/css/userData.css" />

            <script type="text/html" id="addressListTpl">
    <div class="wrapper addressesList " id="boxlists" style="overflow: auto;">
                <div class="page">
            <div class="page-hd" id="boxlist">
                <div class="header bor-1px-b">
                    <div class="header-left">
                        <a href="javascript:;" class="left-arrow close_wrapper" data-type="list"></a>
                    </div>
                    <div class="header-title">选择地址</div>
                    <div class="header-right"></div>
                </div>
            </div>
                        <div class="page-bd">
                <ul class="addresslist goodslist">

                </ul>
            </div>
            <div class="page-ft" id="bottom" style="position: fixed;width: 100vw;bottom: 0;z-index: 9999;background:#fff;border-top: 1px solid rgba(0,0,0,.1)">
                <a href="javascript:;" class="fs32 fw_b color_w BGcolor_r add_address">新增收货地址</a>
            </div>
        </div>
    </div>

    <div class="wrapper addressInfoBox">

    </div>
</script>
            <script src="../../static/js/jquery/jquery-weui.min.js"></script>

            <!--地址列表-->

            <script type="text/html" id="addressLiTpl">
    {{each data as item index}}
    <li>
        {{if item.is_default==1 }}
        <div class="top block" data-index="{{index}}">
            <div class="address" data-index="{{index}}">
                <div class="info">
                    <div>
                        <p class="fs30 fw_b color_3">{{item.userName}} {{item.telNumber}}</p>{{if item.is_default==1 }} <span class="fs22 color_w BGcolor_r">默认</span>{{/if}}
                        <div class="radioBox">

                            <a href="javascript:;" class="edit fs26 color_9" data-index="{{index}}"><img src="../../static/mobile/default/images/edit.png" alt=""><em>编辑</em></a>
                        </div>
                    </div>
                    <span class="fs28 color_9">{{item.full_region}}{{item.detailInfo}}</span></div>

            </div>
        </div>
        {{/if}}
         {{/each}}
         {{each data as item index}}
        {{if item.is_default!=1 }}
        <object>
                <div class="block" data-index="{{index}}">
                    <div class="address" data-index={{index}}">
                        <div class="info">
                            <div>
                                <p class="fs30 fw_b color_3">{{item.userName}} {{item.telNumber}}</p>{{if item.is_default==1 }} <span class="fs22 color_w BGcolor_r">默认</span>{{/if}}
                                <div class="radioBox">

                                    <a href="javascript:;" class="edit fs26 color_9" data-index="{{index}}"><img src="../../static/mobile/default/images/edit.png" alt="">编辑</a>
                                </div>
                            </div>
                            <span class="fs28 color_9">{{item.full_region}}{{item.detailInfo}}</span></div>

                    </div>


                </div>
                <div class="swiped BGcolor_3">
                    <div class="delect" data-address_id="{{item.address_id}}"><img src="../../static/mobile/default/images/delectIcon.png" alt=""></div>
                </div>
            </object> {{/if}}

    </li>
    {{/each}}
</script>

<script type="text/html" id="addressInfoTpl">
   
    <div class="page-hd">
        <div class="header bor-1px-b">
            <div class="header-left">
                <a href="javascript:;" class="left-arrow close_wrapper" data-type="list"></a>
            </div>
            <div class="header-title">{{if id }}修改地址{{else}}添加地址{{/if}}</div>
            <div class="header-right" onclick="evalPost();">保存</div>
        </div>
    </div>
    <form action="" id="formAddress">
        <div class="page-bd ">
            <!-- 页面内容-->
            <div class="cells">
                <div class="cell">
                    <div class="cell_bd"><span class="fs28 color_9">收货人</span></div>

                    <div class="cell_ft">
                        <input type="text" class="fs28  color_3" placeholder="请输入收货人姓名" name="userName" value="{{userName}}">
                    </div>
                </div>
                <div class="cell">
                    <div class="cell_bd">
                        <span class="fs28 color_9">手机号码</span></div>
                    <div class="cell_ft">
                        <input type="Number" class="fs28  color_3" placeholder="请输入收货人电话" name="telNumber" value="{{telNumber}}">
                    </div>
                </div>
                <div class="cell bankType cell_access">
                    <div class="cell_bd">
                        <span class="fs28 color_9">所在地区</span></div>
                    <div class="cell_ft">
                        <input type="text" value="{{full_region}}" placeholder="请选择所在区域" class="fs28 fw_b color_3 bankBox" readonly="" id="city-picker" data-code="{{district}}" data-codes="{{province}},{{city}},{{district}}">
                    </div>
                </div>
                <div class="cell">
                    <div class="cell_bd">
                        <span class="fs28 color_9">详细地址</span></div>
                    <div class="cell_ft">
                        <input type="text" class="fs28  color_3" placeholder="请输入详细地址" name="detailInfo" value="{{detailInfo}}">
                    </div>
                </div>
                <div class="cell">
                    <div class="cell_bd">
                        <span class="fs28 color_9">是否设置为默认地址</span></div>
                    <div class="cell_ft">
                        {{if is_default==1}}
                        <input type="checkbox" name="is_default" id="male" value="1" checked class="chooseBtn" /> {{else}}
                        <input type="checkbox" name="is_default" id="male" value="1" class="chooseBtn" /> {{/if}}
                        <label for="male" class="choose-label"></label>
                    </div>
                </div>
            </div>
            <input type="hidden" name="id" value="{{id}}">

            <div class="page-ft userData">
                <!--<a class="fs32 color_w fw_b BGcolor_r postAddress" onclick="evalPost();">{{if id }}确认修改{{else}}确认添加{{/if}}</a>-->
                {{if id }}
                <a class="fs32 color_w fw_b BGcolor_r delect" data-address_id="{{id}}">删除地址</a> {{/if}}
            </div>
        </div>
        </div>
        </from>
</script>

            <script type="text/javascript">
                var isAddOrder = '1';
                var addressList = {};
                var defAddressId = 0;
                
                      share()
     function  share(){
    /***用户点击分享到微信圈后加载接口接口*******/
        var url=window.location.href;
        console.log("url:"+url);
            $.ajax({
		    url: "/api/mp/wxconfig",
		    type: "post",
		    data:{shareUrl:url},
		    headers:{ token: $.cookie('code')},
		    dataType: "json",
		    success: function(data){
		         configData = {
                    debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                    appId: data.data.appid, // 必填，公众号的唯一标识
                    timestamp: data.data.timestamp, // 必填，生成签名的时间戳
                    nonceStr: data.data.nonceStr, // 必填，生成签名的随机串
                    signature: data.data.signature,// 必填，签名，见附录1
                    jsApiList : ['hideOptionMenu']
                    // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
               };
               
               //step2:注入配置信息
               wx.config(configData);
               //step3:通过ready接口处理成功验证
               wx.ready(function () {
                   // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
//                 alert("执行ready方法");
//                 wx.checkJsApi({
//                      jsApiList: ['chooseImage'] // 需要检测的JS接口列表，所有JS接口列表见附录2,
//                      success: function(res) {
//                      // 以键值对的形式返回，可用的api值true，不可用为false
//                      // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
//                      }
//                 });
                   //接口1:获取网络类型
                    wx.getNetworkType({
                        success: function (res) {
                          oldNet = res.networkType; // 返回网络类型2g，3g，4g，wifi
//                        alert("网络类型"+ oldNet);
                        }
                     });
                   //禁用右上角菜单按钮
                   wx.hideOptionMenu();
		    })
		    },
		    error: function() {
// 			    _alert('ajax request failed!!!!');
			    return;
		    } 
        })

	    
	    
	    }
                $(function () {

                    $("body").append(template('addressListTpl'));
                    var bottom_h = $("#bottom").height();
                    var window_height = $(window).height();
                    var boxlist_h = $("#boxlist").height();
                    var header_h = $(".header").height();
                    if (isAddOrder == 1) header_h = 0;
                    var h = window_height - bottom_h - header_h;
                    $("#boxlists").css('height', h + 'px');
                })

                //获取收货地址区列表
                function getAddressList() {

                    var address_id = $('#address_id').val();
                    jq_ajax('https://mp.jianguoes.com/api/mp/listAddr', '', function (res) {
                        console.log(res);
                        if (res.code == 0) {
                            _alert(res.errmsg);
                            return false;
                        }
                        addressList = res.data;
                        if (isAddOrder == 1) {

                            if (res.data.length == 0) {
                                $('.addressBox .tips').show();
                                $('.addressBox .address').hide();
                                return false;
                            }


                            if (address_id == 0) {
                                for(var i =0; i<res.data.length;i++){
                                   if(res.data[i].is_default ==1){
                                       showAddress(addressList[i]);
                                        defAddressId = addressList[i]['id'];
                                   }
                                
                                }
                                
                                //evalShippingFee(); //计算运费
                            }

                           
                        }

                        $('.addresslist').html(template('addressLiTpl', res));
                        container('.addresslist object')
                    }, 'get')
                }

                //设置显示指定收货地址
                function showAddress(address) {
                    $('.address').find('._consignee').html(address.userName + ' ' + address.telNumber);
                    $('.address').find('._address').html(address.full_region + ' ' + address.detailInfo);
                    $('#address_id').val(address.id);
                }

                $(function () {
                    getAddressList();
                })
                     //点击删除地址
    $(document).on('click', '.addresslist .delect', function() {
            jq_ajax('https://mp.jianguoes.com/api/mp/delAddr', 'id=' + $(this).data('address_id'), function(res) {
                if (res.code == 0) {
                    alert(res.errmsg);
                    return false;
                }
                window.location.reload()
            },'get')
        })
        //编辑页删除地址
    $(document).on('click', '.userData .delect', function() {
            jq_ajax('https://mp.jianguoes.com/api/mp/delAddr', 'id=' + $(this).data('address_id'), function(res) {
                if (res.code == 0) {
                    alert(res.errmsg);
                    return false;
                }
                window.location.reload()
            },'get')
        })
                //关闭编缉弹出
                $(document).on('click', '.addressInfoBox .close_wrapper', function () {
                    $('html').removeClass('noscroll');
                    $('.addressInfoBox').removeClass('move-left');
                })

                //点击新增地址
                $(document).on('click', '.add_address', function () {
                    $('html').addClass('noscroll');
                    $('.addressInfoBox').html(template('addressInfoTpl'));
                    $('.addressInfoBox').addClass('move-left');
                    $("#city-picker").cityPicker({
                        title: "请选择省市区"
                    });
                })
                //点击编缉收货地址
                $(document).on('click', '.addresslist .edit', function () {
                    isContainer = true;
                    $('.addressInfoBox').html(template('addressInfoTpl', addressList[$(this).data('index')]));
                    $('html').addClass('noscroll');
                    $('.addressInfoBox').addClass('move-left');
                    $("#city-picker").cityPicker({
                        title: "请选择省市区"
                    });
                })
                //提交修改或添加操作
                function evalPost() {
                    
                    if(!$('input[name=userName]').val()){
            _alert('请输入收货人姓名');
            return
        }else if(!$('input[name=telNumber]').val()){
            _alert('请输入收货人电话');
            return
        }else if($('input[name=telNumber]').val().length <11){
            _alert('请输入正确的电话');
            return
        }else if(!$('input[id=city-picker]').attr('data-code')){
            _alert('请选择所在区域');
            return
        }else if(!$('input[name=detailInfo]').val()){
            _alert('请输入详细地址');
            return
        }
                     var postData = $('#formAddress').toJson()
                    postData.nationalCode = $('#city-picker').attr('data-code');
                    postData.full_region = $('#city-picker').val();
                    var str = postData.full_region.split(" ")
                    postData.cityName = str[1];
                    postData.countyName = str[2];
                    postData.provinceName =str[0];
                    var url = 'https://mp.jianguoes.com//api/mp/saveOrUpdateAddr';
                    jq_ajax(url, JSON.stringify(postData), function (res) {
                        if (res.errno != 0) {
                            _alert(res.errmsg);
                            return false;
                        }
                        $('.addressBox .tips').hide();
                        $('.addressBox .address').show();
                        addressList = res.list;
                        $('.addresslist').html(template('addressLiTpl', res));
                        container('.addresslist object');
                        $('.addressInfoBox .close_wrapper').trigger("click");
                        getAddressList();
                    })
                }
                //设置为默认地址
                $(document).on('click', '.addresslist .editDefault', function () {
                    var obj = $(this);
                    if (defAddressId != obj.val()) {
                        jq_ajax('/member/api.address/editdefault.html', 'address_id=' + $(this).val(), function (res) {
                            if (res.code == 0) {
                                _alert(res.errmsg);
                                return false;
                            }
                            defAddressId = obj.val();
                        })
                    }

                })
            </script>
            <script type="text/javascript">
                //计算运费

                function evalShippingFee() {
                    if (is == 0) {
                        return false;
                    }
                    var arr = new Object;
                    arr.address_id = $('#address_id').val();
                    arr.recids = rec_id;
                    $('.shippingFee').html('<span style="font-size:80%;">运费计算中...</span>');
                    jq_ajax('/shop/api.flow/evalshippingfee.html', arr, function (res) {
                        if (res.code == 0) {
                            $('.shippingFee').html(res.errmsg);
                            return false;
                        }
                        shippingFee = res.shippingFee.shipping_fee;
                        supplyerShippingFee = res.shippingFee.supplyerShippingFee;
                        evalPrice();
                    })
                }
                //显示收货地址
                $(document).on('click', '.addressBox', function () {
                    $('html').addClass('noscroll');
                    $('.addressesList').addClass('move-left');
                });
                //关闭弹出
                $(document).on('click', '.addressesList .close_wrapper', function () {
                    $('html').removeClass('noscroll');
                    $('.addressesList').removeClass('move-left');
                })
                //点击选择收货地址
                $(document).on('click', '.addresslist .block', function () {
                    var address_id = $('#address_id').val();
                    if (address_id < 1) {
                        $('.sss1').css('display', 'none');
                    }
                    if (isAddOrder == 0) return false;
                    var obj = $(this);
                    setTimeout(function () { //在单击事件中添加一个setTimeout()函数，设置单击事件触发的时间间隔
                        if (isContainer == true) {
                            return isContainer = false;
                        }
                        showAddress(addressList[obj.data('index')]);
                        $('.close_wrapper').trigger("click");
                        getAddressList();
                        // evalShippingFee();
                    }, 100);
                })
            </script>
            <!-- 购物车 -->
            <div class="goodslist" style="padding-bottom:0px;">
                <div class="goodsList">
                    <div style="line-height: 100px; text-align: center">数据加载中..</div>
                </div>
                <div class="inputBox bor_t">
                    <span class="fs28 color_3">留言</span><input type="text" placeholder="请输入" class="fs26 color_3"
                        id="buyMsg">
                    <p class="fs28 color_9 num" id="wordNum">0/140</p>
                </div>
            </div>
            <div class="cellBox">
                <div class="color_3 cell">
                    <span class="fs28">商品金额</span>
                    <div class="color_3 fs28 num money">
                        <p class="fw_b fm_p">￥</p><em class="fs34 totalGoodsPrice">0.00</em>
                    </div>
                </div>
            <!--    <div class="color_3 cell">-->
            <!--<span class="fs28">折扣</span>-->
            <!--<div class="color_3 fs28 num money">-->
            <!--    <p class="fw_b fm_p">-￥</p><em class="fs34 totalDiscount">0.00</em>-->
            <!--</div>-->
        <!--</div>-->
                  <div class="color_3 cell useBonus" onclick="useBonus()">
            <span class="fs28">现金劵</span>
            <div class="color_3 fs28 num money bouns_money">
               <p class="fw_b fm_p" style='color:red'>请选择</p>
            </div>
        </div>  
                <!--<div class="color_3 cell">-->
                <!--    <span class="fs28">运费</span>-->
                <!--    <div class="color_3 fs28 num money">-->
                <!--        <p class="fw_b fm_p">￥</p><em class="fs34 shippingFee">0.00</em>-->
                <!--    </div>-->
                <!--</div>-->
        <!--        <div class="color_3 cell">-->
        <!--    <span class="fs28">（是/否）使用现金劵</span>-->
        <!--    <div class="color_3 fs28 num money"><input type="checkbox" name="Pick"/></div>-->
        <!--</div>-->
                <!--<div class="color_3 cell use_integral hide">
            <span class="fs28">积分：</span>
            <div class="color_3 fs28 num money">
                <p class="fw_b fm_p">-</p><em class="fs34 integralTotal"></em></div>
        </div>-->
            </div>
        </div>

        <div class="paymentbox">
            <div class="left"><span class="fs28 color_9">实付</span>
                <div class="color_3 fs30 num money payTotal">
                    <p class="fw_b fm_p">￥</p><em class="fs52">00</em><span>.00</span>
                </div>
                <span class="color_9 fs28 num money use_integral hide"> + 积分<i
                        class="color_3 fs52 integralTotal"></i></span>
            </div>
            <div class="gopay fs28 fw_b color_w BGcolor_r">立即支付</div>
        </div>
        <!-- 支付方式 -->
        <div class="model payModel">
            <div class="modelContent">
                <div class="closeBox"><img src="../../static/mobile/default/images/close_icon.png" alt=""></div>
                <div class="title fs36 color_3 fw_b">请选择支付方式</div>
                <div class="cantre pay" id="payListBox">

                    <p class="get_list_tip">加载中...</p>

                </div>
                <div class="buttBox">
                    <span class="fs32 fw_b color_w BGcolor_r payConfirm">确认支付</span>
                </div>
            </div>
        </div>
        
         <div class="model bonusModel">
            <div class="modelContent">
                <div class="closeBox"><img src="../../static/mobile/default/images/close_icon.png" alt=""></div>
                <div class="title fs36 color_3 fw_b">请选择现金卷</div>
                <div class="cantre pay" id="bonusListBox">

                    <p class="get_list_tip">加载中...</p>

                </div>
                <div class="buttBox">
                    <span class="fs32 fw_b color_w BGcolor_r bonusConfirm">确认</span>
                </div>
            </div>
        </div>
        <link rel="stylesheet" href="../../static/mobile/default/css/payment.css?v=1" />
        <link rel="stylesheet" href="../../static/mobile/default/css/userData.css" />
        <link rel="stylesheet" href="../../static/mobile/default/css/wallet.css" />
        <style>
            .text {
                padding: .2rem;
            }

            .account {
                background-color: #fff;
            }

            .oblock {
                margin: 0 .2rem .08rem;
                border-radius: .066667rem;
            }

            .oblock .type {
                display: flex;
                align-items: center;
                margin-bottom: .133333rem;
            }

            .oblock {
                display: flex;
                align-items: center;
                justify-content: center;
                flex-direction: column;
                padding: .2rem 0;
                background-color: #ff00000a;
            }

            .oblock .type img {
                width: .266667rem;
                height: .266667rem;
                margin-right: .053333rem;
            }

            .weixinCode {
                width: 1.466667rem;
                height: 1.466667rem;
            }

            .oblock p {
                margin: .1rem 0 .2rem;
            }

            .chongzhi .button {
                width: 4.466667rem;
                margin: 0.266667rem 0.2rem;
                height: 0.533333rem;
                display: -webkit-box;
                display: -webkit-flex;
                display: flex;
                -webkit-box-pack: center;
                -webkit-justify-content: center;
                justify-content: center;
                -webkit-box-align: center;
                -webkit-align-items: center;
                align-items: center;
            }

            .offlinepage {
                position: absolute;
                top: 0;
                left: 100%;
                width: 100%;
                height: 100%;
                overflow: auto;
                z-index: 999;
            }
        </style>

        <script>

            var fd = new FormData();
            var imgNum = 0;

            //选择上传图片
            function uploadFile(_this, e) {

                var formData = new FormData($("#uploadForma")[0])  //创建一个forData
                formData.append('file', $('#uploadInput')[0].files[0]) //把file添加进去  name命名为img
                $.ajax({
                    url: '/member/api._passport/proposal_img.html',
                    data: formData,
                    type: "POST",
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function (data) {

                        if (data.code == 1) {
                            _alert(data.msg);
                            return false;

                        }
                        imgNum++;
                        fd.append("imgfile[" + imgNum + "]", data.url);
                        $('#uploaderFiles1').before('<div class="Box"><img src="' + data.url + '" alt="" class="imgBox payimg"><img src="../../static/mobile/default/images/closeImg.png" alt="" data-imgnum="' + imgNum + '" class="closeImg"></div>');
                    },
                    error: function () {
                        //失败
                    }

                });

            }
            function hideoff() {
                $('.offlinepage').css('left', '100%');
                offlineChoose = false;
            }
        </script>
        <script src="../../static/mobile/default/js/uploadsimage.js?v=1"></script>
        <script>
            //处理点击改变的调用函数-做IOS兼容
            $(_listenSelector).click(function () {
                var that = $(this);

                _uplocalfunction = function (base64Img) {
                    fd.append("qrcodefile", base64Img);
                    $(that).parent().before('<div class="Box"><img src="' + base64Img + '" alt="" class="imgBox payimg"><img src="../../static/mobile/default/images/closeImg.png" alt="" class="closeImg" data-type="one"></div>');
                    $('#upload_qrcode_box').css('visibility', 'hidden');
                    //$(_listenSelector).hide();
                }

            })
        </script>
        <script type="text/html" id="goodsListTpl">
    {{each cartList as skuKey index}} 
     {{if index == 0}}
    <div class="title fs32 color_3 fw_b">
        商品信息
        <div class="color_r fs24" id="shipping_fee_child_{{index}}" style="position: absolute;right: 10px;font-weight: normal;"></div>
    </div>
    {{else if supplyerList}}
    <div class="title fs32 color_3 fw_b">
        <span>{{supplyerList[index]}}</span>
        <div class="color_r fs24 " id="shipping_fee_child_{{index}}" style="position: absolute;right: 10px;font-weight: normal;"></div>
    </div>
    {{/if}} 
    {{if skuKey.checked == 1}}
    <div class="checkbox">
        <a >
            <img src="{{skuKey.list_pic_url}}" alt="" class="goodsimg">
        </a>
        
        <div class="info">
            <p class="fs28 color_3">{{skuKey.goods_name}}</p>
            <div class="sign fs28 color_9">{{skuKey.sku_name}}</div>
            <div class="Money">
                <div class="left">
                    <div class="color_3 fs24 num">
                        <p class="fw_b fm_p">￥</p><em class="fs36">{{skuKey.retail_price}}</em>
                    </div>
                    <span class="fs24 color_9">{{skuKey.source_price}}</span>
                </div>
                <div class="number">
                    <!-- <img src="../../static/mobile/default/images/goodsIcon05.png" onClick="editNum(this,'{{skuKey.goods_id}}','down');" class="minus"> -->
                    x <input class="fs30 color_3" type="text" readonly value="{{skuKey.number}}">
                    <!-- <img src="../../static/mobile/default/images/goodsIcon06.png" onClick="editNum(this,'{{skuKey.goods_id}}','up');" class="add"></div> -->
            </div>
        </div>
        </div>
        
    </div>
    {{/if}}
    {{/each}}
</script>

        <script type="text/html" id="payListTpl">
    <div class="block">
        <label for="other" style="width: 100%;">
            <div class="payType">
                <img src="../../static/mobile/default/images/balancePay.png" alt="">
                <div>
                    <span class="fs30 color_3">余额支付</span>
                    <span class="fs26 color_r">(￥{{mlsuser.allProfit}})</span>
                </div>
            </div>
        </label>
        <label for="other">
            <div class="iconBox">
                <input type="radio" class="check" name="pay_id" value="other" id="other">
                <i class="icon_checked"></i>
            </div>
        </label>
    </div>
    <div class="block">
        <label for="wxpay" style="width: 100%;">
            <div class="payType">
                <img src="../../static/mobile/default/images/weixinPay.png" alt="">
                <div>
                    <span class="fs30 color_3">微信支付</span>
                </div>
            </div>
        </label>
        <label for="wxpay">
            <div class="iconBox">
                <input type="radio" class="check" name="pay_id" value="wxpay" id="wxpay">
                <i class="icon_checked"></i>
            </div>
        </label>
    </div>
    <div class="block">
        <label for="popay" style="width: 100%;">
            <div class="payType">
                <img src="../../static/mobile/default/images/icon_money.png" alt="">
                <div>
                    <span class="fs30 color_3">积分支付</span>
                    <span class="fs26 color_r">(￥{{mlsuser.points}})</span>
                </div>
            </div>
        </label>
        <label for="popay">
            <div class="iconBox">
                <input type="radio" class="check" name="pay_id" value="popay" id="popay">
                <i class="icon_checked"></i>
            </div>
        </label>
    </div>
</script>

     <script type="text/html" id="bonusListTpl">
     {{each $data as item index}}
    <div class="block">
        <label for="other" style="width: 100%;">
            <div class="payType" style='display:block;line-height:2'>
                
                <div >
                    <span class="fs30 color_3">{{item.name}}：{{item.coupon_number}}</span>
                    <span class="fs32 color_r">{{item.coupon_price}}元</span>
                </div>
                <div>可用日期：<span class="fs30 color_3">{{item.use_end_date}}</span></div>
            </div>
        </label>
        <label for="{{item.user_coupon_id}}">
            <div class="iconBox">
                <input type="checkbox" class="check" name="bonus_id" value="{{item.coupon_price}}" id="{{item.user_coupon_id}}">
                <i class="icon_checked"></i>
            </div>
        </label>
    </div>
    {{/each}}
</script>

    </div>

    <script src="../../static/js/art-template.js"></script>
    <script src="../../static/mobile/default/js/lib/fastclick.js"></script>
    <script src="../../static/js/jquery/lazyload/jquery.lazyload.js"></script>
    <script>
        $(function () {
            FastClick.attach(document.body);
            $("img.lazy").lazyload({ effect: "fadeIn", event: "scroll", container: $(".page-bd") });
        });
    </script>


    <script>
        var rec_id = '1314';
        var is = 1;
        //购物车统一请求
        function evalCart(action, arr) {
             if(getUrlParam('type')){
                    arr.type = 'other'
                }else{
                    arr.type = 'cart'
                }
           
            jq_ajax('https://mp.jianguoes.com' + action, arr, function (res) {
                if (res.code == 0) {
                    if (res.errmsg != '') _alert(res.errmsg);
                    return false;
                }
                // if (action == 'getList') {
                //     if (res.cartInfo.allGoodsNum < 1) {
                //         _alert('请选择需购买的商品.', '/shop/index/index.html');
                //         return false;
                //     }
                // }
                $('.goodsList').html(template('goodsListTpl', res.data));
                var  totalAmount = 0,totaldiscount = 0;
                for(var i=0;i<res.data.cartList.length;i++){
                    totalAmount+=res.data.cartList[i].retail_price*res.data.cartList[i].number
                    totaldiscount+=res.data.cartList[i].retail_price*res.data.cartList[i].number
                }
                $('.totalGoodsPrice').html(totalAmount);
                $('.totalDiscount').html(totalAmount-totaldiscount);
                // if (res.cartInfo.integralTotal > 0) {
                //     $('.use_integral').removeClass('hide');
                //     $('.integralTotal').html(res.cartInfo.integralTotal);
                // }
                orderTotal = totalAmount;
                totalGoodsPrice = totaldiscount;
                if (action == 'editNum') {
                    shippingFee = res.shippingFee.shipping_fee;
                    supplyerShippingFee = res.shippingFee.supplyerShippingFee;
                    $('.bonusInfo .ticket').show();
                    $('.bonusInfo .usdinfo').html('')
                }
                
                var test = $('.usebonus')
                 if(res.data.couponList.length >0){
                    $('.useBonus').show()
                    bonus_list = res.data.couponList
                }else{
                   $('.useBonus').hide() 
                }
                evalPrice();
                
               
                return true;
            }, 'get')
        }
        //计算支付金额
        function evalPrice() {
            var payTotal = parseFloat(totalGoodsPrice) + parseFloat(shippingFee) - parseFloat(bonus_money);
            payTotal = payTotal.toFixed(2);
            if(payTotal <= 0){
                payTotal = 0.01;
                $('.payTotal').find('em').html(0);
                $('.payTotal').find('span').html('.01');
            }else{
                payTotal = payTotal.split(".");
                $('.payTotal').find('em').html(payTotal[0]);
                $('.payTotal').find('span').html('.' + payTotal[1]);
            }
            payTotalTemp = payTotal;

            $('.shippingFee').html(shippingFee);
            if (Object.keys(supplyerShippingFee).length > 1) {
                $.each(supplyerShippingFee, function (i, v) {
                    $('#shipping_fee_child_' + i).html('运费：￥' + v);
                })
            }
        }
        //修改购物车订购数量
        function editNum(obj, recid, type) {
            var num = $(obj).parent().find('input').val();
            if (type == 'up') {
                num++;
            } else {
                num--;
            }
            if (num < 1) return false;
            var address_id = $('#address_id').val();
            return evalCart('editNum', 'rec_id=' + recid + '&num=' + num + '&address_id=' + address_id + '&recids=' + rec_id);
        }
        evalCart('/api/mp/checkoutList',{}); //获取购买商品列表
        //选择现金卷
         function useBonus(){
             
                     $('#bonusListBox').html(template('bonusListTpl', bonus_list));
                    $('.bonusModel').show();

         }
        $(function () {
            countTxtEvent("buyMsg", "wordNum", 140);
             
            //选择支付方式
            $('.gopay').on('click', function () {
                if($('#address_id').val() ==0){
                    _alert('请先添加地址')
                    return
                }
                let data = { 'type': "1" };
                jq_ajax('https://mp.jianguoes.com/api/mp/getUserInfo', data, function (res) {
                    if (res.errno != 0) {
                        _alert(res.errmsg);
                        return false;
                    }
                    $('#payListBox').html(template('payListTpl', res.data));
                    $('.payModel').show();
                }, 'get');
            });
          
            $('.closeBox').on('click', function () {
                $('.model').hide();
            });
            var order_Id = ''
            //下单
            $('.buttBox .payConfirm').on('click', function (event) {
                var arr = new Object();
                arr.couponIds = used_bonus_id;
                arr.postscript = $('#buyMsg').val();
                if(getUrlParam('type')){
                    arr.type = 'other'
                }else{
                    arr.type = 'cart'
                }
                
                arr.addressId = $('#address_id').val();
                if (arr.address_id < 1) {
                    _alert('请设置收货地址后，再操作.');
                    return false;
                }
                arr.pay_id = $("input[name='pay_id']:checked").val();
                if (typeof (arr.pay_id) == 'undefined' || arr.pay_id < 1) {
                    _alert('请选择支付方式.');
                    return false;
                }
                
                if(!order_Id){
                    if(arr.pay_id == 'popay'){
                        // 积分支付不会消耗优惠券
                        arr.couponIds = "";
                    }
                    jq_ajax('https://mp.jianguoes.com/api/mp/submitOrder', arr, function (res) {
                    if (res.errno != 0) {
                        _alert(res.errmsg);
                        return false;
                    }
                    order_Id = res.data.id
                    var orderId = {
                        orderId: res.data.id
                    }
                    if(arr.pay_id == 'other'){
                     jq_ajax('https://mp.jianguoes.com/api/mp/amountpay', orderId, function (res) {
                        if (res.errno != 0) {
                             window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/payfail.html?orderId="+orderId.orderId+'&orderMoney='+payTotalTemp;
                            return false;
                        }
                        
                         //支付成功跳转到支付成功页面,并不是真正到账
                        window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/paysuccess.html?orderId="+orderId.orderId+'&orderMoney='+payTotalTemp;
                    }, 'get')
                }else if(arr.pay_id == 'popay'){
                            jq_ajax('https://mp.jianguoes.com/api/mp/pointspay', orderId, function (res) {
                                if (res.errno != 0) {
                                    window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/payfail.html?orderId="+orderId.orderId+'&orderMoney='+payTotalTemp;
                                    return false;
                                }

                                //支付成功跳转到支付成功页面,并不是真正到账
                                window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/paysuccess.html?orderId="+orderId.orderId+'&orderMoney='+payTotalTemp;
                            }, 'get')
                        }else{
                     jq_ajax('https://mp.jianguoes.com/api/mp/prepay', orderId, function (res) {
                        if (res.errno != 0) {
                            _alert(res.errmsg);
                            return false;
                        }
                        console.log(res);
                        onBridgeReady(res.data,orderId.orderId)
                        // window.location.href = '/shop/flow/done/order_id/done.html';
                    }, 'get')
                }
                    // window.location.href = '/shop/flow/done/order_id/done.html';
                   
                }, 'get')
                }else{
                     if(arr.pay_id == 'other'){
                     jq_ajax('https://mp.jianguoes.com/api/mp/amountpay', {orderId: order_Id}, function (res) {
                        if (res.errno != 0) {
                            _alert(res.errmsg);
                            return false;
                        }
                        
                         //支付成功跳转到支付成功页面,并不是真正到账
                        window.location.href = "./done/order_id/paysuccess.html?orderId="+order_Id+'&orderMoney='+payTotalTemp;
                    }, 'get')
                }else{
                     jq_ajax('https://mp.jianguoes.com/api/mp/prepay', {orderId: order_Id}, function (res) {
                        if (res.errno != 0) {
                           window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/payfail.html?orderId="+orderId.orderId+'&orderMoney='+payTotalTemp;
                            return false;
                        }
                        console.log(res);
                        onBridgeReady(res.data,order_Id)
                        // window.location.href = '/shop/flow/done/order_id/done.html';
                    }, 'get')
                }
                
                }
            event.stopPropagation()
            })
            
            //确认现金卷
            $('.bonusConfirm').on('click', function (event) {
                
                bonus_id = $("input[name='bonus_id']:checked").val();
                if (typeof (bonus_id) == 'undefined' || bonus_id < 1) {
                    _alert('请选择现金券.');
                    return false;
                }
                
                var obj = $("input[name='bonus_id']");
                for (var i = 0; i < obj.length; i++) {
                    if (obj[i].checked){
                         used_bonus_id += obj.eq(i).attr('id')+',';
                         bonus_money += Number(obj[i].value)
                    }
                       
                }
                console.log('bonus_money',bonus_money)
                console.log('used_bonus_id',used_bonus_id)
                evalPrice();
                $('.bonusModel').hide()
                $('.bouns_money').html('<p class="fw_b fm_p">-￥</p><em class="fs34 ">'+bonus_money+'</em>')
                 event.stopPropagation()
            
            })
            
            

            function onBridgeReady(params,order_id) {
                console.log(params);
                WeixinJSBridge.invoke(
                    'getBrandWCPayRequest', {
                    "appId": params.appId,     //公众号名称，由商户传入     
                    "timeStamp": params.timeStamp,         //时间戳，自1970年以来的秒数     
                    "nonceStr": params.nonceStr, //随机串     
                    "package": params.package,
                    "signType": params.signType,         //微信签名方式：     
                    "paySign": params.paySign //微信签名 
                },
                    function (res) {
                        var last = JSON.stringify(res); //将JSON对象转化为JSON字符
                        if(res.err_msg === "get_brand_wcpay_request:ok" ) {
                            //支付成功跳转到支付成功页面,并不是真正到账
                            window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/paysuccess.html?orderId="+order_id+'&orderMoney='+payTotalTemp;
                        }
                        if (res.err_msg === "get_brand_wcpay_request:cancel") {
                            //交易取消时需要更新账户和充值记录
                            window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/payfail.html?orderId="+order_id+'&orderMoney='+payTotalTemp;
                        }
                        if (res.err_msg === "get_brand_wcpay_request:fail") {
                            //交易取消时需要更新账户和充值记录
                             window.location.href = "https://mp.jianguoes.com/shop/flow/done/order_id/payfail.html?orderId="+order_id+'&orderMoney='+payTotalTemp;
             }
                    });
            }
            // if (typeof WeixinJSBridge == "undefined") {
            //     if (document.addEventListener) {
            //         document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            //     } else if (document.attachEvent) {
            //         document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            //         document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            //     }
            // } else {
            //     onBridgeReady();
            // }


        })
    </script>

    <div class="alertBox">
        <div class="alertBG"></div>
        <div class="alert">
            <div class="text fs30 color_3 bor_b">

            </div>
            <!-- 单按钮 -->
            <div class="button fs32 fw_b color_r">
                知道了
            </div>
            <!-- 双按钮 -->
            <div class="buttonBox fs32 fw_b">
                <span class="color_9 bor_r cancel">取消</span>
                <span class="color_r confirm">确定</span>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var is_xcx = 0;
        $(document).on('click', 'a', function () {
            var href = $(this).attr('href');
            if (href.indexOf('/pages') != -1) {
                if (is_xcx == 1) {
                    wx.miniProgram.navigateTo({
                        url: href
                    })
                    return false;
                } else {
                    return false;
                }
            }
        })
    </script>
</body>

</html>